using MOKA.TPM.Utility.Const;
using SqlSugar;
using System.ComponentModel.DataAnnotations;

namespace MOKA.TPM.Entity;

/// <summary>
/// 点检设备
/// </summary>
[Tenant(TPMConst.TPMConfigId)]
[SugarTable("Checkup", "点检设备")]
public class Checkup
{
    /// <summary>
    /// 序号
    /// </summary>
    [SugarColumn(ColumnName = "Id", ColumnDescription = "序号", IsPrimaryKey = true)]
    public Guid Id { get; set; }

    /// <summary>
    /// 设备编号
    /// </summary>
    [SugarColumn(ColumnName = "EquipmentId", ColumnDescription = "设备编号")]
    public Guid EquipmentId { get; set; }

    /// <summary>
    /// TPM设备分组
    /// </summary>
    [SugarColumn(ColumnName = "TPMDeviceGroupId", ColumnDescription = "TPM设备分组")]
    public Guid TPMDeviceGroupId { get; set; }

    /// <summary>
    /// 点检任务
    /// </summary>
    [SugarColumn(ColumnName = "CheckupTaskId", ColumnDescription = "点检任务")]
    public Guid? CheckupTaskId { get; set; }

    /// <summary>
    /// 点检周期
    /// </summary>
    [SugarColumn(ColumnName = "CheckupCycle", ColumnDescription = "点检周期")]
    public Guid CheckupCycle { get; set; }

    /// <summary>
    /// 当前周期
    /// </summary>
    [SugarColumn(ColumnName = "CurrentCycle", ColumnDescription = "当前周期", Length = 50)]
    [Required, MaxLength(50)]
    public string CurrentCycle { get; set; } = string.Empty;

    /// <summary>
    /// 点检人
    /// </summary>
    [SugarColumn(ColumnName = "CheckupMan", ColumnDescription = "点检人", Length = 20)]
    [MaxLength(20)]
    public string? CheckupMan { get; set; }

    /// <summary>
    /// 点检日期
    /// </summary>
    [SugarColumn(ColumnName = "CheckupTime", ColumnDescription = "点检日期")]
    public DateTime? CheckupTime { get; set; }

    /// <summary>
    /// 点检任务状态
    /// </summary>
    [SugarColumn(ColumnName = "CheckupStatus", ColumnDescription = "点检任务状态")]
    public Guid? CheckupStatus { get; set; }

    /// <summary>
    /// 点检结果
    /// </summary>
    [SugarColumn(ColumnName = "CheckupResult", ColumnDescription = "点检结果")]
    public Guid? CheckupResult { get; set; }

    /// <summary>
    /// 图片存储标志
    /// </summary>
    [SugarColumn(ColumnName = "ImageId", ColumnDescription = "图片存储标志")]
    public long? ImageId { get; set; }

    /// <summary>
    /// 备注
    /// </summary>
    [SugarColumn(ColumnName = "Remark", ColumnDescription = "备注", Length = 200)]
    [MaxLength(200)]
    public string? Remark { get; set; }

    /// <summary>
    /// 确认人
    /// </summary>
    [SugarColumn(ColumnName = "ConfirmMan", ColumnDescription = "确认人", Length = 20)]
    [MaxLength(20)]
    public string? ConfirmMan { get; set; }

    /// <summary>
    /// 确认时间
    /// </summary>
    [SugarColumn(ColumnName = "ConfirmTime", ColumnDescription = "确认时间")]
    public DateTime? ConfirmTime { get; set; }

    /// <summary>
    /// 创建用户
    /// </summary>
    [SugarColumn(ColumnName = "CreateUser", ColumnDescription = "创建用户", Length = 20)]
    [Required, MaxLength(20)]
    public string CreateUser { get; set; } = string.Empty;

    /// <summary>
    /// 创建时间
    /// </summary>
    [SugarColumn(ColumnName = "CreateTime", ColumnDescription = "创建时间")]
    public DateTime CreateTime { get; set; }

    /// <summary>
    /// 更新用户
    /// </summary>
    [SugarColumn(ColumnName = "UpdateUser", ColumnDescription = "更新用户", Length = 20)]
    [MaxLength(20)]
    public string? UpdateUser { get; set; }

    /// <summary>
    /// 更新时间
    /// </summary>
    [SugarColumn(ColumnName = "UpdateTime", ColumnDescription = "更新时间")]
    public DateTime? UpdateTime { get; set; }

    /// <summary>
    /// EquipmentId (设备编号) 对应的外键实体
    /// </summary>
    [Navigate(NavigateType.ManyToOne, nameof(EquipmentId), nameof(Equipment.Id))]//多对一
    public Equipment equipment_EquipmentId { get; set; }

    /// <summary>
    /// TPMDeviceGroupId (TPM设备分组) 对应的外键实体
    /// </summary>
    [Navigate(NavigateType.ManyToOne, nameof(TPMDeviceGroupId), nameof(SysDictDetail.Id))]//多对一
    public SysDictDetail sysDictDetail_TPMDeviceGroupId { get; set; }

    /// <summary>
    /// CheckupTaskId (点检任务) 对应的外键实体
    /// </summary>
    [Navigate(NavigateType.ManyToOne, nameof(CheckupTaskId), nameof(CheckupTask.Id))]//多对一
    public CheckupTask checkupTask_CheckupTaskId { get; set; }

    /// <summary>
    /// CheckupCycle (点检周期) 对应的外键实体
    /// </summary>
    [Navigate(NavigateType.ManyToOne, nameof(CheckupCycle), nameof(SysDictDetail.Id))]//多对一
    public SysDictDetail sysDictDetail_CheckupCycle { get; set; }

    /// <summary>
    /// CheckupMan (点检人) 对应的外键实体
    /// </summary>
    [Navigate(NavigateType.ManyToOne, nameof(CheckupMan), nameof(T_USER.UserName))]//多对一
    public T_USER t__USER_CheckupMan { get; set; }

    /// <summary>
    /// CheckupStatus (点检任务状态) 对应的外键实体
    /// </summary>
    [Navigate(NavigateType.ManyToOne, nameof(CheckupStatus), nameof(SysDictDetail.Id))]//多对一
    public SysDictDetail sysDictDetail_CheckupStatus { get; set; }

    /// <summary>
    /// CheckupResult (点检结果) 对应的外键实体
    /// </summary>
    [Navigate(NavigateType.ManyToOne, nameof(CheckupResult), nameof(SysDictDetail.Id))]//多对一
    public SysDictDetail sysDictDetail_CheckupResult { get; set; }

    /// <summary>
    /// ImageId (图片存储标志) 对应的外键实体
    /// </summary>
    [Navigate(NavigateType.ManyToOne, nameof(ImageId), nameof(SysFile.Id))]//多对一
    public SysFile sysFile_ImageId { get; set; }

    /// <summary>
    /// CreateUser (创建用户) 对应的外键实体
    /// </summary>
    [Navigate(NavigateType.ManyToOne, nameof(CreateUser), nameof(T_USER.UserName))]//多对一
    public T_USER t__USER_CreateUser { get; set; }

    /// <summary>
    /// UpdateUser (更新用户) 对应的外键实体
    /// </summary>
    [Navigate(NavigateType.ManyToOne, nameof(UpdateUser), nameof(T_USER.UserName))]//多对一
    public T_USER t__USER_UpdateUser { get; set; }

    /// <summary>
    /// 子表：点检记录详情
    /// </summary>
    [Navigate(NavigateType.OneToMany, nameof(CheckupDetail.CheckupId))]//一对多
    public List<CheckupDetail> CheckupDetails { get; set; }
}